{% comment %}
#    Copyright 2012 New Mexico EPSCoR
#
#    This file is part of Teacher's P.E.T.
#
#    Teacher's P.E.T. is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    Teacher's P.E.T. is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with Teacher's P.E.T..  If not, see <http://www.gnu.org/licenses/>.
{% endcomment %}
<h1>
    <a class="AddButton button floatleft" href="{% course_url management app='activities' command='edit' %}" title="Add a new Activity">+</a>
    Activities
</h1>
{% if DownloadAllEnabled %}<a class="button smallbutton floatright" href="{% course_url management app='activities' command='download_all' %}" title="Download all activity submissions">Download All</a>{% endif %}
<div class="clear"></div>
{% if Activities %}
<table border="0" class="indent activities">
    <tr><th class="heading">Category</th><th class="heading">Title</th><th class="heading">General Options</th><th colspan="100%" class="heading">Grading Options</th></tr>
    {% for activity in Activities %}
        <tr>
            <th class="left_justify">
                {{activity.category}}
            </th>
            <th class="left_justify">
                {{activity.indent|safe}} {{activity.title|safe}}
            </th>
            <td rowspan="2">
                <a class="button smallbutton" href="{% course_url management app='activities' command='edit' arguments=activity.category_slug|add:'&'|add:activity.title_slug %}" title="Edit this activity">Edit</a>
                <a class="button smallbutton" href="{% course_url management app='activities' command='remove' arguments=activity.category_slug|add:'&'|add:activity.title_slug %}" title="Remove this activity from the course (and deletes it if it is no longer associated with a course)">Remove</a>
                {% if activity.questions.all %}
            </td>
            <td rowspan="2">
                <a class="button smallbutton" href="{% course_url management app='activities' command='results' arguments=activity.category_slug|add:'&'|add:activity.title_slug %}" title="View collocated responses">Results</a>
                <a class="button smallbutton" href="{% course_url management app='activities' command='download' arguments=activity.category_slug|add:'&'|add:activity.title_slug %}" title="Download all the responses for this activity">Download</a>
                <a class="button smallbutton" href="{% course_url management app='grades' command='manage' arguments=activity.category_slug|add:'&&'|add:activity.title_slug %}" title="Grade this activity">Grade</a>
                <a class="button smallbutton" href="{% course_url management app='activities' command='remind' arguments=activity.category_slug|add:'&'|add:activity.title_slug %}" title="Email students who haven't completed this activity with a reminder" target="_blank">Remind</a>
                {% endif %}
                
            </td>
        </tr>
        <tr>
            <th></th>
            <th colspan="100%" class="left_justify">
                {% if activity.sections.count > 0 %}
                    {% with completed_dict=activity.get_completed_info %}
                    <div class="expansion_container">
                        <span class="expansion_title"><a><span class="arrow_down"></span>({{completed_dict.percent|stringformat:".1f"}}% Completed)</a></span>
                    <div class="expansion_content">
                        <table class="small_table">
                            <tr>
                                <td>
                                    <table border="1" cellpadding="5">
                                        <tr>
                                            <th colspan="100%">Completed&nbsp;({{completed_dict.num_complete}})</th>
                                        </tr>
                                        <tr>
                                            <th>Name</th>
                                            <th>Views</th>
                                            <th>First</th>
                                            <th>Last</th>
                                            <th>Completed</th>
                                        </tr>
                                    {% for item in completed_dict.completed %}
                                        {% with user=item.user %}
                                        {% with data=item.data %}
                                        <tr>
                                            <td>{{ user.last_name }},&nbsp;{{ user.first_name }}</td>
                                            <td>{{ data.times_viewed }}</td>
                                            <td>{{ data.first_viewed|date:"m/d/y H:i"|default:"Never" }}</td>
                                            <td>{{ data.last_viewed|date:"m/d/y H:i"|default:"Never" }}</td>
                                            <td>{{ data.completed|date:"m/d/y H:i"|default:"Never" }}</td>
                                        </tr>
                                        {% endwith %}
                                        {% endwith %}
                                    {% endfor %}
                                    </table>
                                </td>
                                <td>
                                    <table border="1" cellpadding="5">
                                        <tr>
                                            <th colspan="100%">Not&nbsp;Completed&nbsp;({{completed_dict.num_incomplete}})</th>
                                        </tr>
                                        <tr>
                                            <th>Name</th>
                                            <th>Views</th>
                                            <th>First</th>
                                            <th>Last</th>
                                        </tr>
                                    {% for item in completed_dict.notcompleted %}
                                        {% with user=item.user %}
                                        {% with data=item.data %}
                                        <tr>
                                            <td>{{user.last_name}},&nbsp;{{user.first_name}}</td>
                                            <td>{{data.times_viewed}}</td>
                                            <td>{{data.first_viewed|date:"m/d/y H:i"|default:"Never"}}</td>
                                            <td>{{data.last_viewed|date:"m/d/y H:i"|default:"Never"}}</td>
                                        </tr>
                                        {% endwith %}
                                        {% endwith %}
                                    {% endfor %}
                                    </table>
                                </td>
                            </tr>
                        </table>
                        <div class="expansion_footer"><span class="arrow_up"></span></div>
                    {% endwith %}
                    </div>
                    </div>
                {% else %}&nbsp;
                {% endif %}
            </th>
        </tr>
    {% endfor %}
</table>
{% else %}
    <p>No Activities have been created yet</p>
{% endif %}

<h1>
    <a class="AddButton button floatleft" href="{% course_url management app='activities' command='edit_template' %}" title="Add a new Activity Template">+</a>
    Activity Templates
</h1>
<div class="clear"></div>
{% if Templates %}
<table class="indent">
    <tr><th class="heading">Category</th><th class="heading">Title</th><th class="heading">Description</th><th colspan="100%" class="heading">Options</th></tr>
    {% for template in Templates %}
        <tr>
            <th class="left_justify">{{template.category}}</th>
            <th class="left_justify">{{template.title}}</th>
            <th class="left_justify">{{template.description}}</a></th>
            <td class="management_option">
                <a class="button smallbutton" href="{% course_url management app='activities' command='edit' arguments='&&'|concat:template.id %}" title="Create a new Activity using this Template">Create Activity</a>
                <a class="button smallbutton" href="{% course_url management app='activities' command='edit_template' arguments=template.id %}">Edit</a>
                <a class="button smallbutton" href="{% course_url management app='activities' command='copy_template' arguments=template.id %}">Copy</a>
                <a class="button smallbutton" href="{% course_url management app='activities' command='remove_template' arguments=template.id %}">Delete</a>
            </td>
        </tr>
    {% endfor %}
</table>
{% else %}
    <p>No Templates have been created yet</p>
{% endif %}

